package kr.co.gruming;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class LoginServlet
 */
@WebServlet("/Login")
public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		String id = request.getParameter("userid");

		if (id == "") {
			response.sendRedirect("loginForm.html");
		}
		else {
			String pw = request.getParameter("passwd");

			HttpSession se = request.getSession();
			se.setAttribute("userid", id);
			se.setAttribute("passwd", pw);

			response.setContentType("text/html; charset=utf-8");
			PrintWriter out = response.getWriter();

			out.print("안녕하세요 " + id + " 님 <br>");
			out.print("<a href='LoginInfo'>정보보기</a>");
		}

	}

}
